﻿@using wychuan2.com.Models
@model AC.Service.DTO.Blog.BlogsDTO
@{
    Layout = "../Shared/_LayoutBootstrap.cshtml";
    ViewBag.Title = @Model.Title;
}

@{
    if (!Model.IsPublic)
    {
        if (!ApplicationUser.IsLogin())
        {
            Response.Redirect("/admin");
        }
    }
}

@section styles{
    <style type="text/css">
        .content11 {
            width: 700px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
}
@if (!Model.IsPublic && ApplicationUser.Current.UserId != Model.AuthorId)
{
    <div class="text-center m-t-lg"><strong class="text-navy">你没有读此随笔的权限</strong></div>
}
else
{
<div class="bs-docs-header" id="content" tabindex="-1">
    <div class="container">
        <h1>@Model.Title</h1>
        <p>@Model.Summary</p>
    </div>
</div>
<div class="container bs-docs-container">
    <div class="row">
        <div class="col-md-9" role="main">
            @if (Model.BlogSections != null)
            {
                foreach (var blogSection in Model.BlogSections)
                {
                    <div class="bs-docs-section">
                        <h1 id="@("b"+blogSection.SectionId)" class="page-header">@blogSection.Title</h1>
                        @Html.Raw(blogSection.Content)
                        @if (blogSection.Childs != null)
                        {
                            foreach (var child in blogSection.Childs)
                            {
                                <h2 id="@("b"+child.SectionId)">
                                    @child.Title
                                </h2>
                                @Html.Raw(child.Content)
                            }
                        }
                    </div>
                }
            }
        </div>
        <div class="col-md-3" role="complementary">
            <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix-top">
                <ul class="nav bs-docs-sidenav">
                    @if (Model.BlogSections != null)
                    {
                        foreach (var blogSection in Model.BlogSections)
                        {
                            <li>
                                <a href="#@("b"+blogSection.SectionId)">@blogSection.Title</a>
                                @if (blogSection.Childs != null || blogSection.Anchors!=null)
                                {
                                    <ul class="nav">
                                        @if (blogSection.Anchors != null)
                                        {
                                            foreach (var anchor in blogSection.Anchors)
                                            {
                                                <li><a href="#@anchor.AnchorId">@anchor.AnchorText</a></li>
                                            }
                                        }
                                        @if (blogSection.Childs != null)
                                        {
                                            foreach (var child in blogSection.Childs)
                                            {
                                                <li><a href="#@("b"+child.SectionId)">@child.Title</a></li>
                                                if (child.Anchors != null)
                                                {
                                                    foreach (var childAnchor in child.Anchors)
                                                    {
                                                        <li><a href="#@childAnchor.AnchorId">@childAnchor.AnchorText</a></li>
                                                    }
                                                }
                                            }
                                        }
                                    </ul>
                                }
                            </li>
                        }
                    }
                </ul>
                <a class="back-to-top" href="#top">
                    返回顶部
                </a>
                <a href="javascript:;" class="bs-docs-theme-toggle" role="button">
                    主题预览
                </a>
            </nav>
        </div>
    </div>
</div>
}
